import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
import { ShaderModule } from './shader/shader.module';
import { ModelModule } from './model/model.module';
import { ScheduleModule } from '@nestjs/schedule';
import { MongooseModule } from '@nestjs/mongoose';
import { JwtModule } from '@nestjs/jwt';
import { WebGameModule } from './web-game/web-game.module';
import { SpecialEffectsModule } from './special-effects/special-effects.module';
import { OpenApiModule } from './open-api/open-api.module';
import { TypeOrmModule } from '@nestjs/typeorm';
import { commentsBase, videoBase } from './open-api/open-api.entity';
import { jwtConstants } from './global-type';
import { SystemUserModule } from './system-user/system-user.module';
import { SystemLogModule } from './system-log/system-log.module';

@Module({
  imports: [
    TypeOrmModule.forRoot({
      type: 'mariadb',
      host: 'localhost',
      port: Number(process.env.mySQL_PORT),
      username: process.env.mySQL_CONNECT_OPTS_USER,
      password: process.env.mySQL_CONNECT_OPTS_PASS,
      database: process.env.mySQL_CONNECT_OPTS_DBNAME,
      entities: [videoBase,commentsBase],
      synchronize: true,
    }),
    MongooseModule.forRoot(process.env.MONGO_URL, {
      auth: {
        username: process.env.MONGO_CONNECT_OPTS_USER,
        password: process.env.MONGO_CONNECT_OPTS_PASS,
      },
      dbName: process.env.MONGO_CONNECT_OPTS_DBNAME,
    }),
    JwtModule.register({
      secret: jwtConstants.secret,
      signOptions: { expiresIn: '12h' },
    }),

    ScheduleModule.forRoot(),
    SystemUserModule,
    SystemLogModule,
    ShaderModule,
    ModelModule,
    WebGameModule,
    SpecialEffectsModule,
    OpenApiModule,
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
